<!DOCTYPE html>
<html>
<body>

<h2>Upload File</h2>
<form action="http://127.0.0.1:5000/upload" method="post" enctype="multipart/form-data">
  Select file to upload:
  <input type="file" name="file" id="file">
  <input type="submit" value="Upload File" name="submit">
</form>

<script>
  // JavaScript 用于处理文件上传
  const form = document.querySelector('form');
  form.addEventListener('submit', (e) => {
    e.preventDefault();
    const file = document.getElementById('file').files[0];
    const formData = new FormData();
    formData.append('file', file);

    fetch('http://127.0.0.1:8080/upload_file/', {
      method: 'POST',
      body: formData
    })
    .then(response => response.text())
    .then(text => alert(text))
    .catch(error => alert('File upload error: ' + error));
  });
</script>

</body>
</html>